package com.zhdl.modules.demo.dglProcess;

import com.project.common.util.DelayUtil;
import com.zhdl.modules.demo.testprocess.ChildOptImp;
import com.zhdl.modules.process.BaseProcess;
import com.zhdl.modules.process.service.MainProcessValueProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 工位1 涂胶流程
 */
@Service
@Slf4j
public class WorkPlace1GlueProcess extends BaseProcess {
    @Resource
    DGLProcessInitService dglProcessInitService;
    @Resource
    MainProcessValueProvider mainProcessValueProvider;
    @Override
    public void initProcessList() {
        processBeanList = dglProcessInitService.getGlueProcessList();
    }

    @Override
    public void initHardware() {
        super.initHardware();
        desc = "工位一";
        initProcessList();
        statusHolder.initComplete = true;
        statusHolder.setAuto(true);
        statusHolder.setOptInterface(new ChildOptImp(this){
            @Override
            public void release() {
                super.release();
                //当前周期完成 回调
                mainProcessValueProvider.getValue(MainProcessValueProvider.CHILD_PROCESS_DONE).setValue("1");
                DelayUtil.delayedExecution(500, () -> mainProcessValueProvider.getValue(MainProcessValueProvider.CHILD_PROCESS_DONE).setValue("0"));
            }
        });
    }
}
